/*
 * @(#)DataTask.java 
 *
 * Project: BUS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   vincent     2006-03-06   first release  
 *   ------------ ---------- ---------------------------------------------------
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2005 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 */
package com.hitrust.gs.lib.db.backup;

import java.util.TimerTask;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.util.date.DateUtil;

public class DataTask extends TimerTask {
		
	   public void run(){
			StringBuffer tExpTemp = new StringBuffer();
//			tExpTemp = "exp system/sa@BUS file=d:/xxxx.dmp tables=(scott.EMP,scott.BONUS)";
			tExpTemp.append("exp ");
			tExpTemp.append(GSSystemConfigurator.getParam("gs.connectdatabase"));
			tExpTemp.append(" file="+GSSystemConfigurator.getParam("gs.backuppath")+DateUtil.getCurrentTime("DT", "AD")+".dmp");
			String tTemp=GSSystemConfigurator.getParam("gs.backuptable");
			tExpTemp.append(" buffer=8192000");
			tExpTemp.append(" compress=n");
			tExpTemp.append(" grants=y");
			
			if("all".equals(tTemp.toLowerCase()))
				//tExpTemp.append(" full=y");
				tExpTemp.append(" ");
			else
				tExpTemp.append(" tables=("+tTemp+")");
			int tResult=-1;
			GSLogWriter.debug("tExpTemp="+tExpTemp.toString());
			try {
				//0 成功 1 备份失败
				tResult=new DataOper().dataFunction(tExpTemp.toString());
				GSLogWriter.info(DateUtil.getCurrentTime("DT", "AD")+"==backup data tResult="+tResult);
			} catch (Exception ex) {
				GSLogWriter.error(this,ex.getMessage());
			}
	   }
}
